class Game_info {
    // 首先还是获取html里面的元素
    score: number = 0;
    level: number = 1;
    scoreEle: HTMLElement;
    levelEle: HTMLElement;
    constructor() {
        this.scoreEle = document.querySelector('.score') as HTMLElement;
        this.levelEle = document.querySelector('.level') as HTMLElement;
    }

    // 设置方法使分数自增
    addScore() {
        this.scoreEle.innerHTML = ++this.score + '';
        // 判断分数到什么时候开始升级(我们这里规定每吃五个食物加一分)
        if (this.score % 5 === 0) {
            this.levelUp();
        }
    }

    // 设置等级
    levelUp() {
        // 设置最大难度等级为10级
        if (this.level < 10) {
            this.levelEle.innerText = ++this.level + '';
        }
    }
}

// 暴露数据
export default Game_info